home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-04-28 | 1.8 KB | 73 lines | [TEXT/MPS ] |
- /*
- File: DragUtils.cp
-
- Contains: Useful utility functions when using the Drag Manager.
-
- Written by: Dave Falkenburg and Cameron Esfahani
-
- Copyright: © 1993-94 by Dave Falkenburg, all rights reserved.
-
- Change History (most recent first):
-
- <2> 11/12/94 DRF Added #include to pick up function prototype.
- <1> 9/9/94 DRF first checked in
- */
-
- #include "Sprocket.h"
-
- #include <Folders.h>
-
- Boolean
- DragDestinationIsTheTrash(DragReference theDrag)
- {
- AEDesc dropLocation;
- AEDesc dropFSSpecDesc;
- Boolean wasItDraggedToTrash = false;
- OSErr err;
-
- err = GetDropLocation(theDrag, &dropLocation);
- if (err != noErr)
- return false;
-
- if ((dropLocation.descriptorType != typeNull) &&
- (AECoerceDesc(&dropLocation, typeFSS, &dropFSSpecDesc) == noErr))
- {
- FSSpec * theDropFSSpec;
- CInfoPBRec theCatInfoPB;
- long trashDirID;
- short trashVRefNum;
-
- // If we got here, the drag went to a file system thing
-
- HLock(dropFSSpecDesc.dataHandle);
- theDropFSSpec = (FSSpec *) *dropFSSpecDesc.dataHandle;
-
- theCatInfoPB.dirInfo.ioCompletion = nil;
- theCatInfoPB.dirInfo.ioNamePtr = (StringPtr) &theDropFSSpec->name;
- theCatInfoPB.dirInfo.ioVRefNum = theDropFSSpec->vRefNum;
- theCatInfoPB.dirInfo.ioFDirIndex = 0;
- theCatInfoPB.dirInfo.ioDrDirID = theDropFSSpec->parID;
- if (PBGetCatInfoSync(&theCatInfoPB) != noErr)
- goto bail;
-
- // Is it a directory?
-
- if (!(theCatInfoPB.dirInfo.ioFlAttrib & ioDirMask))
- goto bail;
-
- // Is it the trash folder?
-
- (void) FindFolder(kOnSystemDisk,kTrashFolderType,kCreateFolder,&trashVRefNum,&trashDirID);
-
- if ((theDropFSSpec->vRefNum == trashVRefNum) && (theCatInfoPB.dirInfo.ioDrDirID == trashDirID))
- wasItDraggedToTrash = true;
- }
-
- bail:
- HUnlock(dropFSSpecDesc.dataHandle);
- AEDisposeDesc(&dropFSSpecDesc);
- AEDisposeDesc(&dropLocation);
-
- return wasItDraggedToTrash;
- }
-